$(function () {
    var j = $("#J_SquareBarTabTitle"), h = $("#J_DarenTabTitle"), l = $("#J_DarenTabPanels"), k = $("#J_MyForumBtn"), i = $("#J_MyForumPanels"), m = $("#J_MyTopicPanels");
    $(".sprt-piece").hover(function () {
        $(this).find(".sprt-ico").fadeIn()
    }, function () {
        $(this).find(".sprt-ico").fadeOut()
    });
    $("#J_MyLoveForum").click(function () {
        $.guang.dialog.isLogin()
    });
    j.tabs("#J_SquareBarTabPanels .panels-con", {event:"click", tabs:"li"});
    var n = j.data("tabs");
    $("#J_GoToPrevTab").click(function () {
        n.prev()
    });
    $("#J_ForumPostTabTitle").tabs("#J_ForumPostTabPanels .panels-con",
        {event:"click", rotate:!0, tabs:"li"});
    $("#J_MyJoinedTabTitle").tabs("#J_MyJoinedTabPanels .panels-con", {event:"click", rotate:!0, tabs:"li"});
    $("#J_ForumTabNav a").click(function () {
        var a = $(this), e = a.data("tab");
        if (!a.hasClass("on")) {
            if ("my" == e && !$.guang.dialog.isLogin())return!1;
            $("#J_ForumTabNav a.on").removeClass("on");
            a.addClass("on");
            $(".tab-con:visible").hide();
            $(".tab-con-" + e).show()
        }
    });
    if ($("#J_DarenTabTitle")[0]) {
        h.tabs("#J_DarenTabPanels li", {event:"mouseover", tabs:"li", rotate:!0});
        var o = h.data("tabs"),
            f = function () {
                darenTabInterval = setInterval(function () {
                    o.next()
                }, 4E3)
            };
        f();
        h.find("li").hover(function () {
            clearInterval(darenTabInterval)
        }, function () {
            f()
        });
        l.find("li").hover(function () {
            clearInterval(darenTabInterval)
        }, function () {
            f()
        })
    }
    var d = {getData:function (a, e, d, c) {
        a.find(".loading").css("display", "block");
        void 0 != a.data("list" + c) ? (a.find("ul").remove(), a.prepend("<ul>" + a.data("list" + c) + "</ul>"), a.find(".loading").css("display", "none")) : $.ajax({url:GUANGER.path + "/square/bar/" + d, type:"get", dataType:"json",
            data:{pageNo:c, pageSize:10}, success:function (b) {
                switch (b.code) {
                    case 100:
                        var d = "userCreate" == e ? b.userCreateForumTopicsPage : b.userReplyForumTopicsPage, b = "userCreate" == e ? b.userCreateForumTopics : b.userReplyForumTopics;
                        if (0 < d && b) {
                            if (b) {
                                var g = "";
                                $.map(b, function (a) {
                                    g += '<li><a class="ofh" href="' + a.redirectUrl + '" title="' + a.title + '">' + a.title + "</a>";
                                    g += "<span>" + a.replyCount + "\u6761\u8bc4\u8bba\uff0c\u6700\u540e\u56de\u590d\uff1a" + a.displayTime + "</span></li>"
                                });
                                a.find("ul").remove();
                                a.prepend("<ul>" + g + "</ul>")
                            }
                            1 ==
                                d ? a.find(".my-pagin").css("display", "none") : a.find(".J_TotalP:first").html(d);
                            a.data("list" + c, g)
                        } else d = "userCreate" == e ? "\u521b\u5efa\u8fc7\u8bdd\u9898\u5594\u2026" : "\u53c2\u52a0\u8fc7\u8ba8\u8bba\u5462\u2026", a.data("haslist", !1), a.html('<p class="no-data">\u60a8\u8fd8\u6ca1\u6709' + d + "</p>");
                        break;
                    case 101:
                        a.html('<p style="color:#d02200;">\u670d\u52a1\u5668\u51fa\u9519\u4e86\uff01</p>')
                }
                a.find(".loading").css("display", "none")
            }, error:function () {
                alert("\u4eb2\uff0c\u5929\u592a\u70ed\uff0c\u670d\u52a1\u5668\u4e2d\u6691\u4e86\uff01\u7a0d\u7b49\u4f1a\u513f\u54e6\uff01")
            }})
    },
        pagination:function (a, e, h) {
            var c = a.find(".my-pagin:first"), b = c.find(".J_CurP:first"), i = c.find(".J_TotalP:first"), g = c.find(".prev:first"), f = c.find(".next:first");
            g.click(function () {
                var c = parseInt(b.text());
                parseInt(i.text());
                1 < c && (f.removeClass("disabled"), b.text(c - 1), d.getData(a, e, h, b.text()), 1 == parseInt(b.text()) ? $(this).addClass("disabled") : $(this).removeClass("disabled"))
            });
            f.click(function () {
                var c = parseInt(b.text()), f = parseInt(i.text());
                c < f && (g.removeClass("disabled"), b.text(c + 1), d.getData(a,
                    e, h, b.text()), b.text() == f ? $(this).addClass("disabled") : $(this).removeClass("disabled"))
            })
        }, init:function () {
            d.pagination(m, "userCreate", "user_create");
            k[0] && (k.click(function () {
                i.data("haslist") && d.getData(i, "userReply", "user_reply", "1")
            }), d.pagination(i, "userReply", "user_reply"))
        }};
    d.init()
});
